﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SMK_Profiler_Core
{
    public class Class1
    {
    }

    public class TraceEventStatistics
    {
        private string _ServerName = string.Empty;
        private SortedList<Microsoft.AnalysisServices.TraceEventClass, long> _TraceStatistics = null;
        public TraceEventStatistics(string ServerName)
        {
            _ServerName = ServerName;
        }

        public long GetTraceEventCount(Microsoft.AnalysisServices.TraceEventClass TraceEventClass)
        {
            if (_TraceStatistics != null && _TraceStatistics.ContainsKey(TraceEventClass))
            {
                return (long)_TraceStatistics[TraceEventClass];
            }
            else
            {
                return 0;
            }
        }

        public void AddTraceEvent(string TraceName, Microsoft.AnalysisServices.TraceEventArgs TraceEvent)
        {
            if (_TraceStatistics == null)
            {
                _TraceStatistics = new SortedList<Microsoft.AnalysisServices.TraceEventClass, long>();
            }
            if (_TraceStatistics.ContainsKey(TraceEvent.EventClass))
            {

                long intcount = _TraceStatistics.Values[_TraceStatistics.IndexOfKey(TraceEvent.EventClass)];
                intcount++;
                _TraceStatistics.Remove(TraceEvent.EventClass);
                //_TraceStatistics.Values[_TraceStatistics.IndexOfKey(TraceEvent.EventClass)] = _TraceStatistics.Values[_TraceStatistics.IndexOfKey(TraceEvent.EventClass)] ++;
                _TraceStatistics.Add(TraceEvent.EventClass, intcount);
            }
            else
            {
                _TraceStatistics.Add(TraceEvent.EventClass, 1);
            }
        }
    }

    public enum SMK_Profiler_MSAS_Types
    {
        Microsoft_AnalysisServices_Cube = 100010,
        Microsoft_AnalysisServices_Database = 100002,
        Microsoft_AnalysisServices_Dimension = 100006,
        Microsoft_AnalysisServices_DimensionAttribute = 100007,
        Microsoft_AnalysisServices_Hierarchy = 100008,
        Microsoft_AnalysisServices_MeasureGroup = 100016,
        Microsoft_AnalysisServices_Partition = 100021
    }
}
